<?php
/**
 * @author spenceryg
 * @date 2022/11/7
 * @time 11:02 上午
 * @focus love & life
 */


namespace app\common\lib;

use Yurun\Util\Chinese;
use Yurun\Util\Chinese\Pinyin;

class SpPinyin
{
    public static function getAll($string): string
    {
        $data = Chinese::toPinyin($string, Pinyin::CONVERT_MODE_PINYIN);
        return implode('', $data['pinyin'][0]);
    }


    public static function getFirst($string): string
    {
        $data = Chinese::toPinyin($string, Pinyin::CONVERT_MODE_PINYIN_FIRST);
        return implode('', $data['pinyinFirst'][0]);
    }
}
